<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <!--      <el-form-item label="学校ID" prop="schId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.schId"-->
      <!--          placeholder="请输入学校ID"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="行政班级" prop="clazzId">
        <el-select
          v-model="queryParams.clazzId"
          style="width: 150px"
          clearable
          placeholder="请选择"
        >
          <el-option
            v-for="item in ClazzList"
            :key="item.cId"
            :label="item.name"
            :value="item.cId"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="教学班级" prop="cId2">
        <el-select
          v-model="queryParams.clazzId2"
          style="width: 150px"
          clearable
          placeholder="请选择"
        >
          <el-option
            v-for="item in Clazz2List"
            :key="item.cId"
            :label="item.name"
            :value="item.cId"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="学制" prop="sysId">
        <el-select
          v-model="queryParams.sysId"
          style="width: 150px"
          clearable
          placeholder="请选择"
        >
          <el-option
            v-for="item in SysList"
            :key="item.sId"
            :label="item.name"
            :value="item.sId"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <!--      <el-form-item label="院系" prop="deptId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.deptId"-->
      <!--          placeholder="请输入院系"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="专业" prop="majorId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.majorId"-->
      <!--          placeholder="请输入专业"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="年级" prop="gradeId">
        <el-select
          v-model="queryParams.gradeId"
          style="width: 150px"
          clearable
          placeholder="请选择"
        >
          <el-option
            v-for="item in GradeList"
            :key="item.gId"
            :label="item.name"
            :value="item.gId"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="学生名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入学生名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入学时间" prop="entrance">
        <el-date-picker
          clearable
          size="small"
          v-model="queryParams.entrance"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择入学时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="联系电话" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入联系电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="QQ" prop="qq">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.qq"-->
      <!--          placeholder="请输入qq"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="邮箱" prop="email">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.email"-->
      <!--          placeholder="请输入邮箱"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="微信" prop="wechat">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.wechat"-->
      <!--          placeholder="请输入微信"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="户籍地址" prop="address1">
        <el-input
          v-model="queryParams.address1"
          placeholder="请输入户籍地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学历状态" prop="education">
        <el-select
          v-model="queryParams.education"
          style="width: 150px"
          clearable
          placeholder="请选择"
        >
          <el-option key="1" value="1" label="单招"></el-option>
          <el-option key="2" value="2" label="成考"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="现居地址" prop="address2">
        <el-input
          v-model="queryParams.address2"
          placeholder="请输入现居地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="打卡地址" prop="address3">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.address3"-->
      <!--          placeholder="请输入打卡地址"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="毕业学校" prop="school">
        <el-input
          v-model="queryParams.school"
          placeholder="请输入毕业学校"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="年龄" prop="age">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.age"-->
      <!--          placeholder="请输入年龄"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="性别" prop="gender">
        <el-select
          v-model="queryParams.gender"
          style="width: 150px"
          placeholder="请选择"
          clearable
        >
          <el-option value="1" label="男"></el-option>
          <el-option value="2" label="女"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="身份证号" prop="card">
        <el-input
          v-model="queryParams.card"
          placeholder="请输入身份证号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出生日期" prop="birthday">
        <el-input
          v-model="queryParams.birthday"
          placeholder="请输入出生日期"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="父亲姓名" prop="parent1">
        <el-input
          v-model="queryParams.parent1"
          placeholder="请输入父亲姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="父亲联系方式" prop="parent1Phone">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.parent1Phone"-->
      <!--          placeholder="请输入父亲联系方式"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="父亲身份证号" prop="parent1Card">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.parent1Card"-->
      <!--          placeholder="请输入父亲身份证号"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="母亲姓名" prop="parent2">
        <el-input
          v-model="queryParams.parent2"
          placeholder="请输入母亲姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="母亲联系方式" prop="parent2Phone">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.parent2Phone"-->
      <!--          placeholder="请输入母亲联系方式"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="母亲身份证号" prop="parent2Card">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.parent2Card"-->
      <!--          placeholder="请输入母亲身份证号"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="缴费状态" prop="tuition">
        <el-radio-group v-model="queryParams.tuition" size="small">
          <el-radio-button label="1">已交第一年</el-radio-button>
          <el-radio-button label="2">已交第二年</el-radio-button>
          <el-radio-button label="3">已交第三年</el-radio-button>
          <el-radio-button label="4">已交第四年</el-radio-button>
        </el-radio-group>
        <!--        <el-input-->
        <!--          v-model="queryParams.tuition"-->
        <!--          placeholder="请输入缴费状态;1第一年 ,2 第二年 ,3第三年 ,4第四年"-->
        <!--          clearable-->
        <!--          size="small"-->
        <!--          @keyup.enter.native="handleQuery"-->
        <!--        />-->
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['teach:student:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['teach:student:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['teach:student:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['teach:student:import']"
          >导入</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['teach:student:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="clicktest"
          v-hasPermi="['teach:student:export']"
          >多次点击测试</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="studentList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <!--      <el-table-column label="学生" align="center" prop="sId" />-->
      <!--      <el-table-column label="学校" align="center" prop="schId" />-->
      <el-table-column label="学生姓名" align="center" prop="name" />
      <el-table-column label="行政班级" align="center" prop="clazzName">
        <template slot-scope="scope">
          <span>{{
            scope.row.clazzName == null ? "暂未分班" : scope.row.clazzName
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="教学班级" align="center" prop="clazzName2">
        <template slot-scope="scope">
          <span>{{
            scope.row.clazzName2 == null ? "暂未分班" : scope.row.clazzName2
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="学制" align="center" prop="sysName" />
      <!--      <el-table-column label="院系" align="center" prop="deptId" />-->
      <!--      <el-table-column label="专业" align="center" prop="majorId" />-->
      <el-table-column
        label="年级"
        width="100"
        align="center"
        prop="sysGradeName"
      />
      <el-table-column
        label="入学时间"
        align="center"
        prop="entrance"
        width="100"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.entrance, "{y}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="年龄" width="50" align="center" prop="age" />
      <el-table-column label="性别" align="center" prop="gender">
        <template slot-scope="scope">
          <span>{{ scope.row.gender == 1 ? "男" : "女" }}</span>
        </template>
      </el-table-column>
      <el-table-column label="联系电话" align="center" prop="phone" />
      <el-table-column label="身份证号" align="center" prop="card" />

      <el-table-column label="户籍地址" align="center" prop="address1" />
      <el-table-column label="现居地址" align="center" prop="address2" />
      <el-table-column label="缴费状态" align="center" prop="tuition" />
      <!--      <el-table-column label="打卡地址" align="center" prop="address3" />-->
      <el-table-column label="毕业学校" align="center" prop="school" />
      <el-table-column
        label="出生日期"
        align="center"
        width="100"
        prop="birthday"
      />
      <el-table-column label="学制" align="center" prop="sysId">
        <template slot-scope="scope">
          <span
            v-for="(item, index) in SysList"
            :key="index"
            v-show="scope.row.sysId == item.sId"
            >{{ item.name }}</span
          >
        </template>
      </el-table-column>
      <el-table-column label="学历状态" align="center" prop="education">
        <template slot-scope="scope">
          <span v-if="scope.row.education != null">
            {{ scope.row.education == 1 ? "单招" : "成考" }}
          </span>
          <span v-else> 暂未选择 </span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <span
            v-for="item in stuStatus"
            :key="item.id"
            v-show="scope.row.status == item.id"
            >{{ item.name }}</span
          >
        </template>
      </el-table-column>
      <el-table-column label="父亲姓名" align="center" prop="parent1" />
      <el-table-column
        label="父亲联系方式"
        align="center"
        prop="parent1Phone"
      />
      <el-table-column label="父亲身份证号" align="center" prop="parent1Card" />
      <el-table-column label="母亲姓名" align="center" prop="parent2" />
      <el-table-column
        label="母亲联系方式"
        align="center"
        prop="parent2Phone"
      />
      <el-table-column label="母亲身份证号" align="center" prop="parent2Card" />
      <el-table-column label="qq" align="center" prop="qq" />
      <el-table-column label="邮箱" align="center" prop="email" />
      <el-table-column label="微信" align="center" prop="wechat" />

      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column
        label="操作"
        align="center"
        fixed="right"
        width="90"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.status != '3'"
            style="margin-left: 10px"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleDropout(scope.row)"
            >退学</el-button
          >
          <el-button
            style="margin-left: 10px"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="tuixue(scope.row.sId)"
            v-else
            >查看情况</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleTuition(scope.row)"
            >缴费</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['teach:student:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['teach:student:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 学生缴费情况 -->
    <el-dialog
      :title="title"
      :visible.sync="tuition"
      width="600px"
      append-to-body
    >
      <el-form ref="form" :model="tform" :rules="jiaofei" label-width="80px">
        <el-form-item label="学生ID" v-show="false" prop="sId">
          <el-input v-model="form.sId" placeholder="请输入学生ID" />
        </el-form-item>
        <el-form-item label="学生ID" v-show="false" prop="sId">
          <el-input v-model="tform.sId" placeholder="请输入学生ID" />
        </el-form-item>
        <el-form-item label="缴费金额" prop="money">
          <el-input
            v-model="tform.money"
            clearable
            placeholder="请输入缴费金额"
          />
        </el-form-item>
        <el-form-item label="缴费学年" prop="year">
          <el-date-picker
            v-model="tform.year"
            value-format="yyyy"
            type="year"
            placeholder="选择年"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="tform.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="tuitiona">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 学生退学申请 -->
    <el-dialog
      :title="title"
      :visible.sync="statu"
      width="600px"
      append-to-body
    >
      <el-form ref="form" :model="dform" :rules="tuixueru" label-width="120px">
        <el-form-item label="学生Id" prop="sId" v-show="false">
          <el-input v-model="dform.sId" placeholder="请输入学生Id" />
        </el-form-item>
        <el-form-item label="退学原因" prop="reason">
          <el-input v-model="dform.reason" placeholder="请输入退学原因" />
        </el-form-item>
        <el-form-item label="退学相关图片" prop="img">
          <el-upload
            ref="upload"
            :limit="4"
            accept=".jpg, .png"
            :action="uploads.url"
            :headers="uploads.headers"
            :file-list="uploads.fileList"
            :on-progress="handleFileUploadProgresss"
            :on-success="handleFileSuccesss"
            :on-remove="fileremove"
            list-type="picture"
            :auto-upload="true"
          >
            <el-button slot="trigger" size="small" type="primary"
              >选取文件</el-button
            >
            <div slot="tip" class="el-upload__tip">
              只能上传jpg/png文件，且不超过500kb
            </div>
          </el-upload>
        </el-form-item>
        <el-form-item label="是否保留学籍" prop="retain">
          <el-radio v-model="dform.retain" label="1">保留</el-radio>
          <el-radio v-model="dform.retain" label="0">不保留</el-radio>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="dform.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="subtuixue">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 退学信息查询 -->
    <el-dialog
      :title="title"
      :visible.sync="tuixuecha"
      width="600px"
      append-to-body
    >
      <el-form ref="form" :model="dform" label-width="120px">
        <el-form-item label="退学原因" prop="reason">
          <el-input
            v-model="tuixueinfo.reason"
            :disabled="true"
            placeholder="请输入退学原因"
          />
        </el-form-item>
        <el-form-item label="相关图片">
          <el-image
            style="width: 100px; height: 100px"
            v-for="item in tuixueinfo.img"
            :key="item"
            :src="item"
            :preview-src-list="tuixueinfo.img"
            fit="cover"
          >
          </el-image>
        </el-form-item>
        <el-form-item label="是否保留学籍" prop="retain">
          <el-input
            v-if="tuixueinfo.retain == 1"
            :disabled="true"
            value="保留学籍"
          />
          <el-input v-else value="不保留学籍" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input
            v-model="dform.remark"
            :disabled="true"
            placeholder="未备注"
          />
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="guan">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改学生对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="行政班级" prop="clazzId">
          <el-select
            v-model="form.clazzId"
            style="width: 150px"
            clearable
            placeholder="请选择"
          >
            <el-option
              v-for="item in ClazzList"
              :key="item.cId"
              :label="item.name"
              :value="item.cId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="教学班级" prop="clazzId2">
          <el-select
            v-model="form.clazzId2"
            style="width: 150px"
            clearable
            placeholder="请选择"
          >
            <el-option
              v-for="item in Clazz2List"
              :key="item.cId"
              :label="item.name"
              :value="item.cId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学制" prop="sysId">
          <el-select
            v-model="form.sysId"
            style="width: 150px"
            clearable
            placeholder="请选择"
          >
            <el-option
              v-for="item in SysList"
              :key="item.sId"
              :label="item.name"
              :value="item.sId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="院系" prop="deptId">
          <el-select v-model="form.deptId" clearable placeholder="请选择">
            <el-option
              v-for="item in SdeptList"
              :key="item.dId"
              :label="item.name"
              :value="item.dId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="专业" prop="majorId">
          <el-select v-model="form.majorId" clearable placeholder="请选择">
            <el-option
              v-for="item in MajorList"
              :key="item.mId"
              :label="item.name"
              :value="item.mId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="年级" prop="gradeId">
          <el-select v-model="form.gradeId" clearable placeholder="请选择">
            <el-option
              v-for="item in GradeList"
              :key="item.gId"
              :label="item.name"
              :value="item.gId"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="学生名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入学生名称" />
        </el-form-item>
        <el-form-item label="入学时间" prop="entrance">
          <el-date-picker
            clearable
            size="small"
            v-model="form.entrance"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择入学时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="联系电话" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入联系电话" />
        </el-form-item>
        <el-form-item label="qq" prop="qq">
          <el-input v-model="form.qq" placeholder="请输入qq" />
        </el-form-item>
        <el-form-item label="邮箱" prop="email">
          <el-input v-model="form.email" placeholder="请输入邮箱" />
        </el-form-item>
        <el-form-item label="微信" prop="wechat">
          <el-input v-model="form.wechat" placeholder="请输入微信" />
        </el-form-item>
        <el-form-item label="户籍地址" prop="address1">
          <el-input v-model="form.address1" placeholder="请输入户籍地址" />
        </el-form-item>
        <el-form-item label="现居地址" prop="address2">
          <el-input v-model="form.address2" placeholder="请输入现居地址" />
        </el-form-item>
        <el-form-item label="打卡地址" prop="address3">
          <el-input v-model="form.address3" placeholder="请输入打卡地址" />
        </el-form-item>
        <el-form-item label="毕业学校" prop="school">
          <el-input v-model="form.school" placeholder="请输入毕业学校" />
        </el-form-item>
        <el-form-item label="年龄" prop="age">
          <el-input v-model="form.age" placeholder="请输入年龄" />
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-select v-model="form.gender" placeholder="请选择">
            <el-option
              v-for="item in genre"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="身份证号" prop="card">
          <el-input v-model="form.card" placeholder="请输入身份证号" />
        </el-form-item>
        <el-form-item label="学历信息" prop="education">
          <el-select
            v-model="form.education"
            style="width: 150px"
            placeholder="请选择"
          >
            <el-option
              v-for="item in education"
              :key="item.id"
              :value="item.id"
              :label="item.name"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="出生日期" prop="birthday">
          <el-input v-model="form.birthday" placeholder="请输入出生日期" />
        </el-form-item>
        <el-form-item label="父亲姓名" prop="parent1">
          <el-input v-model="form.parent1" placeholder="请输入父亲姓名" />
        </el-form-item>
        <el-form-item label="父亲联系方式" prop="parent1Phone">
          <el-input
            v-model="form.parent1Phone"
            placeholder="请输入父亲联系方式"
          />
        </el-form-item>
        <el-form-item label="父亲身份证号" prop="parent1Card">
          <el-input
            v-model="form.parent1Card"
            placeholder="请输入父亲身份证号"
          />
        </el-form-item>
        <el-form-item label="母亲姓名" prop="parent2">
          <el-input v-model="form.parent2" placeholder="请输入母亲姓名" />
        </el-form-item>
        <el-form-item label="母亲联系方式" prop="parent2Phone">
          <el-input
            v-model="form.parent2Phone"
            placeholder="请输入母亲联系方式"
          />
        </el-form-item>
        <el-form-item label="母亲身份证号" prop="parent2Card">
          <el-input
            v-model="form.parent2Card"
            placeholder="请输入母亲身份证号"
          />
        </el-form-item>
        <el-form-item label="删除标志" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入删除标志" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 学生导入对话框 -->
    <el-dialog
      :title="upload.title"
      :visible.sync="upload.open"
      width="400px"
      append-to-body
    >
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" />
            是否更新已经存在的用户数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link
            type="primary"
            :underline="false"
            style="font-size: 12px; vertical-align: baseline"
            @click="importTemplate"
            >下载模板</el-link
          >
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listStudent,
  getStudent,
  delStudent,
  addStudent,
  updateStudent,
} from "@/api/teach/student";
import { listClazz } from "@/api/teach/clazz";
import { listSys } from "@/api/teach/sys";
import { listGrade } from "@/api/teach/grade";
import { listDept } from "@/api/teach/dept";
import { listMajor } from "@/api/teach/major";
import { getLeave, addLeave, selinfo } from "@/api/teach/leave";
import {
  listStudent_tuition,
  addStudent_tuition,
} from "@/api/teach/student_tuition";
import { getToken } from "@/utils/auth";

export default {
  name: "Student",
  data() {
    return {
      stuStatus: [
        { name: "入学", id: 1 },
        { name: "在籍", id: 2 },
        { name: "退学", id: 3 },
        { name: "结业", id: 4 },
      ],
      uploads: {
        // 是否禁用上传
        isUploading: false,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/common/upload",
        // 上传的文件列表
        fileList: [],
      },
      clicktest1: 0,
      //退学情况遮罩层
      dropout: false,
      tuixuecha: false,
      //退学情况form
      dform: {
        retain: "1",
      },
      //缴费情况遮罩层
      tuition: false,
      //缴费情况form
      tform: {},
      //学历
      education: [
        { name: "单招", id: 1 },
        { name: "成考", id: 2 },
      ],
      //男女
      genre: [
        { name: "男", id: 1 },
        { name: "女", id: 2 },
      ],
      //缴费情况列表
      tuitionList: [
        { name: "第一年", id: 1 },
        { name: "第二年", id: 2 },
        { name: "第三年", id: 3 },
        { name: "第四年", id: 4 },
      ],
      //状态遮罩层
      statu: false,
      //状态列表
      statuList: [
        { name: "在校", id: 1 },
        { name: "退学", id: 2 },
      ],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学生表格数据
      studentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        schId: null,
        clazzId: null,
        clazzId2: null,
        education: null,
        sysId: null,
        deptId: null,
        majorId: null,
        gradeId: null,
        name: null,
        entrance: null,
        phone: null,
        qq: null,
        email: null,
        wechat: null,
        address1: null,
        address2: null,
        address3: null,
        school: null,
        age: null,
        gender: null,
        card: null,
        birthday: null,
        parent1: null,
        parent1Phone: null,
        parent1Card: null,
        parent2: null,
        parent2Phone: null,
        parent2Card: null,
        tuition: null,
        status: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      // 学生导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/teach/student/importData",
      },
      //行政班级条件
      queryClazz: {
        category: 0,
      },
      //行政班级列表
      ClazzList: [],
      //教学班级条件
      queryClazz2: {
        category: 1,
      },
      //教学班级列表
      Clazz2List: [],
      //学制管理
      querySys: {},
      //学制列表
      SysList: [],
      //年级管理
      queryGrade: {},
      //年级列表
      GradeList: [],
      //院系管理
      querySdept: {},
      //院系列表
      SdeptList: [],
      //专业管理
      queryMajor: {},
      //专业列表
      MajorList: [],
      //缴费查询
      queryTuition: {},
      //缴费列表
      Tuitionlist: {},
      //缴费表单验证
      jiaofei: {
        money: [
          { required: true, message: "缴费金额不能为空", trigger: "blur" },
        ],
        year: [
          { required: true, message: "缴费金额不能为空", trigger: "blur" },
        ],
      },
      tuixueru: {
        reason: [
          { required: true, message: "退学原因不可为空", trigger: "blur" },
        ],
      },
      //退学详情
      tuixueinfo: {},
    };
  },
  created() {
    this.getList();
    this.getClazz();
    this.getClazz2();
    this.getSys();
    this.getGrade();
    this.getSdept();
    this.getMajor();
  },
  methods: {
    /** 查询专业 */
    getMajor() {
      listMajor(this.queryMajor).then((response) => {
        this.MajorList = response.rows;
      });
    },
    /** 查询院系 */
    getSdept() {
      listDept(this.querySdept).then((response) => {
        this.SdeptList = response.rows;
      });
    },
    /** 查询年级 */
    getGrade() {
      listGrade(this.queryGrade).then((response) => {
        this.GradeList = response.rows;
      });
    },
    /** 查询学制 */
    getSys() {
      listSys(this.querySys).then((response) => {
        this.SysList = response.rows;
      });
    },
    /** 查询教学班级 */
    getClazz2() {
      listClazz(this.queryClazz2).then((response) => {
        this.Clazz2List = response.rows;
      });
    },
    clicktest() {
      if (this.clicktest1 == 0) {
        console.log(1)
        this.clicktest1 = 1;
        setTimeout(() => {
          this.clicktest1 = 0
        }, 5000);
      } else {
        this.$notify({
          title: "警告",
          message: "请勿重复点击",
          type: "warning",
        });
      }
    },
    /** 查询行政班级 */
    getClazz() {
      listClazz(this.queryClazz).then((response) => {
        this.ClazzList = response.rows;
      });
    },
    /** 查询学生列表 */
    getList() {
      this.loading = true;
      listStudent(this.queryParams).then((response) => {
        this.studentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.tuition = false;
      this.statu = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        sId: null,
        schId: null,
        clazzId: null,
        clazzId2: null,
        sysId: null,
        deptId: null,
        majorId: null,
        gradeId: null,
        name: null,
        entrance: null,
        education: null,
        phone: null,
        qq: null,
        email: null,
        wechat: null,
        address1: null,
        address2: null,
        address3: null,
        school: null,
        age: null,
        gender: null,
        card: null,
        birthday: null,
        parent1: null,
        parent1Phone: null,
        parent1Card: null,
        parent2: null,
        parent2Phone: null,
        parent2Card: null,
        tuition: null,
        status: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        delFlag: null,
        updateTime: null,
        remark: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.sId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加学生";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const sId = row.sId || this.ids;
      getStudent(sId).then((response) => {
        this.form = response.data;
        console.log(this.form);
        console.log(response);
        this.open = true;
        this.title = "修改学生";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.sId != null) {
            console.log(this.form);
            updateStudent(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addStudent(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 修改缴费确定 */
    tuitiona() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.form.tuition = this.form.tuition + 1;
          addStudent_tuition(this.tform).then((response) => {
            updateStudent(this.form).then((res) => {
              this.$modal.msgSuccess("修改成功");
              this.tuition = false;
              this.getList();
            });
          });
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const sIds = row.sId || this.ids;
      this.$modal
        .confirm('是否确认删除学生编号为"' + sIds + '"的数据项？')
        .then(function () {
          // return delStudent(sIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "teach/student/export",
        {
          ...this.queryParams,
        },
        `student_${new Date().getTime()}.xlsx`
      );
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download(
        "teach/student/importTemplate",
        {},
        `student_template_${new Date().getTime()}.xlsx`
      );
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    handleFileUploadProgresss(event, file, fileList) {},
    handleFileSuccesss(res, file, fileList) {
      this.uploads.fileList = fileList;
    },
    fileremove(file, fileList) {
      this.uploads.fileList = fileList;
      if (fileList.length == 0) {
        this.uploads.fileList = [];
      }
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    /** 打开缴费记录 */
    handleTuition(row) {
      this.reset();
      const sId = row.sId || this.ids;
      getStudent(sId).then((response) => {
        this.form = response.data;
        this.tform.sId = response.data.sId;
        this.tuition = true;
        this.title = "缴费记录";
      });
    },
    /** 打开学生状态 */
    handleDropout(row) {
      this.reset();
      const sId = row.sId || this.ids;
      getStudent(sId).then((response) => {
        this.dform.sId = response.data.sId;
        this.form = response.data;
        this.statu = true;
        this.title = "学生状态";
      });
    },
    tuixue(row) {
      selinfo(row).then((response) => {
        this.tuixueinfo = response.data;
        this.tuixueinfo.img = response.data.img.split("##");
        for (let i = 0; i < this.tuixueinfo.img.length; i++) {
          this.tuixueinfo.img[i] =
            process.env.VUE_APP_BASE_API + this.tuixueinfo.img[i];
        }
      });
      this.tuixuecha = true;
      this.title = "退学信息";
    },
    guan() {
      this.tuixuecha = false;
    },
    // 退学信息提交
    subtuixue() {
      var vals = this.uploads.fileList;
      var files = "";
      for (let i = 0; i < vals.length; i++) {
        files = files + vals[i].response.fileName + "##";
      }
      var img = files.substring(0, files.length - 2);
      this.dform.img = img;
      this.form.status = 3;

      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.dform.remark == undefined) {
            this.dform.remark = "";
          }
          updateStudent(this.form).then((response) => {
            addLeave(this.dform).then((res) => {
              this.uploads.fileList = [];
              this.dform = {
                sId: null,
                img: null,
                reason: null,
                remark: "",
                retain: "1",
              };
              this.statu = false;
              this.getList();
            });
          });
        }
      });
    },
  },
};
</script>
